package com.atguigu.srb.sms.controller;

import com.atguigu.srb.base.response.R;
import com.atguigu.srb.sms.service.SmsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/sms")
//@CrossOrigin //跨域
public class SmsController {
    @Resource
    SmsService smsService;
    //发送短信时需要手机号码、发送短信的类型(使用的短信模板不一样)
    @ApiOperation("发送短信：type- 1 注册验证码 、2 登录验证码 ")
    @GetMapping("sendMsg/{mobile}/{type}")
    public R sendMsg(@PathVariable("mobile")String mobile,
                     @PathVariable("type")Integer type){

        smsService.sendMsg(mobile,type);
        return R.ok().msg("短信发送成功");
    }
}
